07. The Covariance Matrix and Quadratic Forms

L3 06 The Covariance Matrix And Quadratic Forms V1

The Covariance Matrix

Let's take a moment to learn a compact way to represent the portfolio variance using matrices and vectors.

Remember that the portfolio variance we calculated for our two-stock portfolio was:

\sigma_P^2 = x_A^2\sigma_A^2 + x_B^2\sigma_B^2 + 2x_Ax_B\mathrm{Cov}(r_A,r_B).

But

\sigma_A^2 = \mathrm{Cov}(r_A,r_A),
so

\sigma_P^2 = x_A^2\mathrm{Cov}(r_A,r_A) + x_B^2\mathrm{Cov}(r_B,r_B) + 2x_Ax_B\mathrm{Cov}(r_A,r_B).

This expression now has a nice parallel structure. If we create a matrix called the covariance matrix,

\mathbf{P} = \begin{bmatrix} \mathrm{Cov}(r_A,r_A) & \mathrm{Cov}(r_A,r_B)\ \mathrm{Cov}(r_B,r_A) & \mathrm{Cov}(r_B,r_B) \end{bmatrix},

and a vector of weights:

\mathbf{x} = \begin{bmatrix} x_A \ x_B \end{bmatrix},

and do the following matrix multiplication:

\begin{bmatrix} x_A & x_B \end{bmatrix} \begin{bmatrix} \mathrm{Cov}(r_A,r_A) & \mathrm{Cov}(r_A,r_B)\\ \mathrm{Cov}(r_B,r_A) & \mathrm{Cov}(r_B,r_B) \end{bmatrix} \begin{bmatrix} x_A \\ x_B \end{bmatrix}
= \begin{bmatrix} x_A & x_B \end{bmatrix} \begin{bmatrix} x_A\mathrm{Cov}(r_A,r_A) + x_B \mathrm{Cov}(r_A,r_B)\\ x_A\mathrm{Cov}(r_B,r_A) + x_B\mathrm{Cov}(r_B,r_B) \end{bmatrix}
=x_Ax_A\mathrm{Cov}(r_A,r_A) + x_Ax_B\mathrm{Cov}(r_A,r_B) + x_Ax_B\mathrm{Cov}(r_A,r_B) + x_Bx_B\mathrm{Cov}(r_B,r_B)
= x_A^2\sigma_A^2 + x_B^2\sigma_B^2 + 2x_Ax_B\mathrm{Cov}(r_A,r_B),

we see that we recover the expression for \sigma_P^2 .

So:
\sigma_P^2 = \mathbf{x}^\mathrm{T}\mathbf{P}\mathbf{x}

Quadratic Forms

A polynomial where the sums of the exponents of the variables in each term equals 2 is called a quadratic form. An example:

4x^2 - 2xy + 3y^2

The portfolio variance is an example of a quadratic form (remember, x_A and x_B are the variables here):

\sigma_P^2 = x_A^2\sigma_A^2 + x_B^2\sigma_B^2 + 2x_Ax_B\mathrm{Cov}(r_A,r_B)

A quadratic form can always been written as \mathbf{x}^\mathrm{T}\mathbf{P}\mathbf{x} , where P is a symmetric matrix.